package cn.tedu.sp03.user.controller;

import cn.tedu.sp01.entity.User;
import cn.tedu.sp01.service.UserService;
import cn.tedu.web.util.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Author 作者：小龙猿
 * @Project 项目：springcloud1
 * @Time 时间：2021/9/9 14:45
 */
@Slf4j
@RestController
public class UserController {
    @Resource(name = "userServiceImpl")
    private UserService userService;
    @GetMapping("/{userId}")
    public JsonResult<User> getUser(@PathVariable Integer userId){
        log.info("get user,userId="+userId);
        User user = userService.getUser(userId);
        return JsonResult.ok(user);
    }
    @GetMapping("/{userId}/score")
    public JsonResult addScore(@PathVariable Integer userId,Integer score){
        userService.addScore(userId, score);
        return JsonResult.ok();
    }
    @GetMapping("/favicon.ico")
    public void ico(){
    }
}
